-- 15
function ccR_Priest_Void_Tendrils(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseTalent = ccRS["Priest_" .. specNumber .. "_UseVoidTendrils"]
	local vHostileCount = ccRS["Priest_" .. specNumber .. "_VoidTendrilsCount"]
	if vUseTalent
	and ccrPlayerHasTalent(VOID_TENDRILS)
	and ccrSpellIsReady(VOID_TENDRILS)
	and # tblPGetNearbyEnemies >= vHostileCount
	then
		ccrCast(VOID_TENDRILS)
		return
	end
	return
end

function ccR_Priest_Psyfiend(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseTalent = ccRS["Priest_" .. specNumber .. "_UsePsyfiend"]
	if vUseTalent
	and ccrPlayerHasTalent(PSYFIEND)
	and ccrSpellIsReady(PSYFIEND)
	then
		local x
		if # tblPGetNearbyEnemies > 0 then
			for x = 0, # tblPGetNearbyEnemies do
				local obj = tblPGetNearbyEnemies[x]
				if obj
				and obj:Exists()
				and (obj:GetTarget():Exists() and obj:GetTarget():GetName() == ccrPlayerName())
				and obj:GetDistance(Player) <= 24
				and obj:InLineOfSight()
				then
					if ccrPlayerIsCastingOrChanneling() then SpellStopCasting() end
					ccrCast(PSYFIEND)
					if SpellIsTargeting() == 1 then CastAtLocation(obj:GetLocation()) end
				end
			end
		end	
		return
	end
	return
end

-- 30
function ccR_Priest_Angelic_Feather(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseTalent = ccRS["Priest_" .. specNumber .. "_UseAngelicFeather"]
	if ccrPlayerHasTalent(ANGELIC_FEATHER)
	and ccrSpellIsReady(ANGELIC_FEATHER)
	and IsMounted() == nil
	and not ccrPlayerHasBuff(ANGELIC_FEATHER)
	and ccrPlayerIsMoving()
	then
		ccrCast(ANGELIC_FEATHER)
		if SpellIsTargeting() == 1 then CastAtLocation(Player:GetLocation()) end
		return
	end	
end

-- 45
function ccR_Priest_From_Darkness_Comes_Light(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseTalent = ccRS["Priest_" .. specNumber .. "_UseMindSpike"]

	if vUseTalent
	and	ccrPlayerHasTalent(FROM_DARKNESS_COMES_LIGHT)
	and ccrPlayerHasBuff(FROM_DARKNESS_COMES_LIGHT)
	and ccrPlayerHasSpell(MIND_SPIKE)
	and ccrSpellCanAttack(MIND_SPIKE)
	then
		if ccrPlayerIsCastingOrChanneling() then SpellStopCasting() end
		ccrCastAttack(MIND_SPIKE)
		return
	end
	return
end

function ccR_Priest_Mindbender(specNumber)
end

-- 60
function ccR_Priest_Desperate_Prayer(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseTalent = ccRS["Priest_" .. specNumber .. "_UseDesperatePrayer"]
	local vHealth = ccRS["Priest_" .. specNumber .. "_DesperatePrayerHP"]
	if vUseTalent
	and ccrPlayerHasTalent(DESPERATE_PRAYER)
	and ccrSpellIsReady(DESPERATE_PRAYER)
	and ccrPlayerHealth() <= vHealth
	then
		ccrCast(DESPERATE_PRAYER, "Player")
		return
	end
	return
end

-- 75
function ccR_Priest_Power_Infusion(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseTalent = ccRS["Priest_" .. specNumber .. "_UsePowerInfusion"]
	local vBossOnly = ccRS["Priest_" .. specNumber .. "_UsePowerInfusionOnBossOnly"]
	if vUseTalent
	and ccrPlayerHasTalent(POWER_INFUSION)
	and ccrSpellIsReady(POWER_INFUSION)
	and ccrPlayerIsInCombat()
	then
		if vBossOnly
		and ccrTargetIsBoss()
		then
			ccrCast(POWER_INFUSION)
			return
		end

		if not vBossOnly then
			ccrCast(POWER_INFUSION)
			return
		end
	end
end

-- 90
function ccR_Priest_Cascade(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseTalent = ccRS["Priest_" .. specNumber .. "_UseCascade"]
	local vEnemyCount = ccRS["Priest_" .. specNumber .. "_CascadeCount"]
	if ccrPlayerHasTalent(CASCADE)
	and ccrSpellIsReady(CASCADE)
	and ccrTargetCount(40) >= vEnemyCount
	then
		ccrCast(CASCADE)
		return
	end
end

function ccR_Priest_Divine_Star(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseTalent = ccRS["Priest_" .. specNumber .. "_UseDivineStar"]
	local vEnemyCount = ccRS["Priest_" .. specNumber .. "_DivineStarCount"]
	if ccrPlayerHasTalent(DIVINE_STAR)
	and ccrSpellIsReady(DIVINE_STAR)
	and ccrTargetCount(12) >= vEnemyCount
	and Target and Target:Exists() and Target:GetDistance(Player) <= 22
	then
		ccrCast(DIVINE_STAR)
		return
	end
end

function ccR_Priest_Halo(specNumber)
	if specNumber == nil then specNumber = ccrSpec() end
	local vUseTalent = ccRS["Priest_" .. specNumber .. "_UseHalo"]
	local vEnemyCount = ccRS["Priest_" .. specNumber .. "_HaloCount"]
	if ccrPlayerHasTalent(HALO)
	and ccrSpellIsReady(HALO)
	and ccrPlayerCount(30) >= vEnemyCount
	and Target and Target:Exists() and Target:GetDistance(Player) <= 28
	then
		ccrCast(HALO)
		return
	end
end